home *** CD-ROM | disk | FTP | other *** search
- Path: frco.com!usenet
- From: Jadam@tcmail.frco.com (Jim Adam)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ Gurus! Is it correct?
- Date: 2 Feb 1996 19:10:54 GMT
- Organization: Fisher Rosemount Systems
- Message-ID: <4etnju$6gn@rolaids.frco.com>
- References: <4eqvtg$cg5@israel-info.datasrv.co.il>
- NNTP-Posting-Host: primrose.frco.com
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.93.11
-
- In article <4eqvtg$cg5@israel-info.datasrv.co.il>, dmitry@enigma.co.il
- says...
-
- >Is next code is correct from point of view of pure C++ ?
-
- >class A
- >{
- >};
-
- >class B
- >{
- >};
-
- >class C : public A, public B
- >{
- >};
-
- >A* pA = new C;
- >B* pB = new C;
-
- >delete pA;
- >delete pB;
-
- ==========================
-
- This is correct. However, to ensure the destructor for class
- C gets called correctly, class A and B both need virtual
- destructors.
-
- E.g.,
-
- class A
- {
- public:
- virtual ~A();
- };
-
- And likewise for class B.
-
- Jim
-
-